package ui;
import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/

public class Intro extends javax.swing.JFrame {
	private JPanel background;
	private JLabel blackboard;
	private JButton BotonSalir;
	private JLabel Title;
	private JButton BotonComenzar;
	private JButton BotonContinuar;
	private JButton BotonOpciones;
	private Partida p;
	private Opciones ops;
	private int dificultad, modo;
	private JLabel info;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				Intro inst = new Intro();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
				
			}
		});
	}
	
	public Intro() {
		super();
		modo=1;
		dificultad=5; //Normal
		initGUI();
	}
	
	private void initGUI() {
		try {
			this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setMaximumSize(new java.awt.Dimension(640, 590));
			this.setMinimumSize(new java.awt.Dimension(640, 590));
			this.addWindowListener(new WindowAdapter() {
				public void windowClosing(WindowEvent evt) {
					thisWindowClosing(evt);
				}
			});
			{
				background = new JPanel();
				getContentPane().add(background, BorderLayout.CENTER);
				background.setLayout(null);
				background.setSize(640, 590);
				{
					Title = new JLabel();
					background.add(Title);
					Title.setText("TRES EN RAYA");
					Title.setBounds(80, 60, 510, 110);
					Title.setBackground(new java.awt.Color(67,85,72));
					Title.setFont(new java.awt.Font("Eraser",1,68));
					Title.setForeground(new java.awt.Color(255,255,255));
					Title.setOpaque(false);
					Title.setBorder(BorderFactory.createEmptyBorder());
				}
				{
					info = new JLabel();
					background.add(info);
					info.setText("Jorge Merino Garcia");
					info.setBounds(480, 505, 120, 20);
					info.setBackground(new java.awt.Color(67,85,72));
					info.setFont(new java.awt.Font("Eraser",1,10));
					info.setForeground(new java.awt.Color(255,255,255));
					info.setOpaque(false);
					info.setBorder(BorderFactory.createEmptyBorder());
				}
				{
					BotonOpciones = new JButton();
					background.add(BotonOpciones);
					BotonOpciones.setText("OPCIONES");
					BotonOpciones.setBackground(new java.awt.Color(67,85,72));
					BotonOpciones.setFont(new java.awt.Font("Eraser",1,20));
					BotonOpciones.setForeground(new java.awt.Color(255,255,255));
					BotonOpciones.setOpaque(false);
					BotonOpciones.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
					BotonOpciones.setBounds(245, 335, 145, 40);
					BotonOpciones.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							BotonOpcionesMouseClicked(evt);
						}
					});
				}
				{
					BotonSalir = new JButton();
					background.add(BotonSalir);
					BotonSalir.setText("SALIR");
					BotonSalir.setBackground(new java.awt.Color(67,85,72));
					BotonSalir.setFont(new java.awt.Font("Eraser",1,20));
					BotonSalir.setForeground(new java.awt.Color(255,255,255));
					BotonSalir.setOpaque(false);
					BotonSalir.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
					BotonSalir.setBounds(245, 380, 145, 40);
					BotonSalir.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							BotonSalirMouseClicked(evt);
						}
					});
				}
				{
					BotonComenzar = new JButton();
					background.add(BotonComenzar);
					BotonComenzar.setText("COMENZAR");
					BotonComenzar.setBounds(245, 290, 145, 40);
					BotonComenzar.setFont(new java.awt.Font("Eraser",1,20));
					BotonComenzar.setForeground(new java.awt.Color(255,255,255));
					BotonComenzar.setBackground(new java.awt.Color(67,85,72));
					BotonComenzar.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
					BotonComenzar.setOpaque(false);
					BotonComenzar.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							BotonComenzarMouseClicked(evt);
						}
					});
				}
				{
					BotonContinuar = new JButton();
					background.add(BotonContinuar);
					BotonContinuar.setText("CONTINUAR");
					BotonContinuar.setBounds(245, 245, 145, 40);
					BotonContinuar.setFont(new java.awt.Font("Eraser",1,20));
					BotonContinuar.setForeground(new java.awt.Color(255,255,255));
					BotonContinuar.setBackground(new java.awt.Color(67,85,72));
					BotonContinuar.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
					BotonContinuar.setOpaque(false);
					BotonContinuar.setVisible(false);
					BotonContinuar.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							BotonContinuarMouseClicked(evt);
						}
					});
				}
				{
					blackboard = new JLabel();
					background.add(blackboard);
					blackboard.setBounds(0, -6, 640, 570);
					blackboard.setIcon(new ImageIcon(getClass().getClassLoader().getResource("ui/pizarra.png")));
				}
			}
			this.setSize(640, 590);
			pack();
			
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	@SuppressWarnings("deprecation")
	private void BotonSalirMouseClicked(MouseEvent evt) {
		System.out.println("BotonSalir.mouseClicked, event="+evt);
		if(p!=null){
			if(p.getCpuvscpu()!=null)
				p.getCpuvscpu().stop();
			p.dispose();
		}
		this.dispose();
	}
	
	@SuppressWarnings("deprecation")
	private void BotonOpcionesMouseClicked(MouseEvent evt) {
		System.out.println("BotonOpciones.mouseClicked, event="+evt);
		if(p!=null){
			if(p.getCpuvscpu()!=null)
				p.getCpuvscpu().stop();
			p.dispose();
		}
		if(ops==null)
			ops=new Opciones(this);
		ops.setVisible(true);
		this.setVisible(false);
	}
	
	@SuppressWarnings("deprecation")
	private void BotonComenzarMouseClicked(MouseEvent evt) {
		System.out.println("BotonComenzar.mouseClicked, event="+evt);
		if(p!=null){
			if(p.getCpuvscpu()!=null)
				p.getCpuvscpu().stop();
			p.dispose();
		}
		p=new Partida(this);
		p.setVisible(true);
		this.setVisible(false);
	}
	
	private void BotonContinuarMouseClicked(MouseEvent evt) {
		System.out.println("BotonComenzar.mouseClicked, event="+evt);
		//TODO add your code for BotonComenzar.mouseClicked
		if(p==null)
			p=new Partida(this);
		p.setVisible(true);
		this.setVisible(false);
	}

	public Opciones getOps() {
		return ops;
	}

	public void setOps(Opciones ops) {
		this.ops = ops;
	}

	public int getDificultad() {
		return dificultad;
	}

	public void setDificultad(int dificultad) {
		this.dificultad = dificultad;
	}

	public int getModo() {
		return modo;
	}

	public void setModo(int modo) {
		this.modo = modo;
	}
	
	public JButton getBotonContinuar() {
		return BotonContinuar;
	}

	@SuppressWarnings("deprecation")
	private void thisWindowClosing(WindowEvent evt) {
		System.out.println("this.windowClosing, event="+evt);
		if(p!=null){
			if(p.getCpuvscpu()!=null)
				p.getCpuvscpu().stop();
			p.dispose();
		}
		this.dispose();
	}

}
